package verbindung;

/**
 * 
 * @author Nilientes
 *
 */
public class DBDSingleton {

	private static DBDClient client=null;
	
	/**
	 * 
	 * @param server
	 * @param port
	 * @param binaryprotokoll
	 */
	public static void init(String server, int port, boolean binaryprotokoll, boolean forcenew)
	{
		if(DBDSingleton.client!=null && forcenew==false)
		{
			System.err.println("DBDSingleton already initialized");
		}
		else{
			if(binaryprotokoll)
				DBDSingleton.client= new DBDClientBin(server, port);
			else
				DBDSingleton.client= new DBDClientText(server, port);
		}
	}
	
	/**
	 * 
	 * @return returns a Client connected to server
	 */
	public static DBDClient getClient()
	{
		if(client==null)
			System.out.println("DBDSingleton not initialized");
		return DBDSingleton.client;
	}
}
